package com.lagou.order.controller;

import com.lagou.common.pojo.Goods;
import com.lagou.common.pojo.OrderDTO;
import com.lagou.common.pojo.Orders;
import com.lagou.order.fegin.GoodsFeign;
import com.lagou.order.service.OrderService;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private OrderService ordersService;

    /**
     * 模拟服务超时，熔断处理
     * 针对熔断处理，Hystrix默认维护一个线程池，默认大小为10。
     *
     * @return
     */

    /*
     * 根据订单id查询订单信息和对应的商品信息
     */
    @GetMapping("/query/{id}")
    public Orders queryById(@PathVariable Integer id){
        Orders order = ordersService.queryById(id);
        return order;
    }
    /*
     * 多条件分页查询，返回总条数和分页数据
     */
    @PostMapping("/queryByPage")
    public Map<String, Object> queryByPage(@RequestBody OrderDTO orderDTO){
        Map<String, Object> map = ordersService.queryByPage(orderDTO);
        return map;
    }
}
